import pytest
import pandas as pd


# all_case = xfile.read("./data/case.xlsx").excel_to_dict(sheet=2)
df = pd.read_excel("./data/case.xlsx", sheet_name=2)
df = df.fillna("")
all_case = df.to_dict(orient="records")

print("读取Excel中的Sheet里的所有数据", all_case)


@pytest.mark.parametrize("test_case", all_case)
def test_excel(keywords, test_case):
    print("正在执行用例：", test_case)
    key = test_case["关键字"]
    print("正在执行关键字：", key)
    key_func = keywords.__getattribute__(key)
    # 把参数传到Keywords的工具箱内容中
    key_func(**test_case)
    keywords.screenshot()


if __name__ == '__main__':
    pytest.main(["-sv", __file__])
